package com.shangqing.common.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class GetWeatherUtil {
    @Autowired
    RestTemplate restTemplate;
    public String  getWeather(){
        /*高德API接口*/
        String weatherUrl = "https://restapi.amap.com/v3/weather/weatherInfo?city=640106&key=ed8913582dbbc7b27152c793cfac49b7";

        /*百度API接口*/
        /* String weatherUrl = "http://api.map.baidu.com/telematics/v3/weather?location=银川&output=json&ak=FK9mkfdQsloEngodbFl4FeY3";*/
        /*第三方接口地址*/
        /*String weatherUrl ="https://tianqiapi.com/api?version=v6&appid=38211743&appsecret=Ue8q3Gxz";*/
        ResponseEntity<String> weatherEntity = restTemplate.getForEntity(weatherUrl, String.class);
        String weatherBody = weatherEntity.getBody();
       return  weatherBody;
    }
}
